package com.sky.happygos.YiPush;

/**
 * Created by qqqqqqq on 2017/4/7.
 */

public class Byte2Int {
    public static int byteArrayToInt32(byte[] b) {
        return   b[3] & 0xFF |
                (b[2] & 0xFF) << 8 |
                (b[1] & 0xFF) << 16 |
                (b[0] & 0xFF) << 24;
    }

    public static byte[] int32ToByteArray(int a) {
        return new byte[] {
                (byte) ((a >> 24) & 0xFF),
                (byte) ((a >> 16) & 0xFF),
                (byte) ((a >> 8) & 0xFF),
                (byte) (a & 0xFF)
        };
    }
    public static byte[] int8ToByteArray(int a) {
        return new byte[] {
                (byte) (a & 0xFF)
        };
    }
    public static int byteArrayToInt8(byte[] b) {
        return   b[0] & 0xFF;
    }
}
